﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using yiwei.Repository.Entity;

namespace yiwei.Repository.EntityConfig
{
    public class ModuleMap : IEntityTypeConfiguration<Module>
    {
        public void Configure(EntityTypeBuilder<Module> builder)
        {
            builder.ToTable("Module");
            builder.HasKey(c => c.Id);
            builder.HasIndex(b => b.Code).IsUnique().HasName("Index_Code"); //唯一索引·
            builder.HasMany(b => b.ModuleElements).WithOne(); ; //导航属性·1对多
            builder.Property(b => b.Url).HasColumnType("varchar(200)");
            builder.Property(b => b.IconName).HasColumnType("varchar(200)");
            builder.Property(b => b.Vector).HasColumnType("varchar(200)");
            builder.Property(b => b.Code).HasColumnType("varchar(200)").IsRequired();
        
        }
    }
}
